< previous page page_141 next page >

Page 141
Chapter 5
Printing
So far this book has explained how to use Visual Basic to draw lines, circles, text, and other simple objects on a computer screen. It has shown how to save images in bitmap files and Windows metafiles. It has said little about displaying things on a printer.
There are several ways you can send output to a printer. The PrintForm method is by far the easiest, but it produces the poorest quality and can be very slow. Using graphic output methods like Line and Circle, you can send graphics directly to a printer. This approach requires much more programming, but it produces better output, and your printer will usually print more quickly. With only a little extra work, you can also provide a print preview feature to let users see what a printout will look like before printing it.
This chapter discusses these methods for creating printed output. It explains ways you can make high-resolution printing easier, and it describes a couple of useful printing routines for producing high-quality output with little additional programming.
Before continuing, however, a word of caution. There are many different kinds of printers, each requiring its own device drivers and operating system support. Different combinations of printer, device driver, operating system, and Visual Basic version can produce different, sometimes disastrous, results.
Printer Objects
When you print in Visual Basic, you work with an object named Printer. Initially, this object represents your system's default printer, but you can make the Printer object represent a different printer if you like.
The Printers collection holds a list of all of the printers available on your system. You can use the items in this collection to print to a different printer or to select a different printer. For example, to make the Printer object represent the first printer in the Printers collection, you could use the statement:
e10a6a0a59f035e870d90cca05b85fce.gif
Set Printer = Printers(0)

 
< previous page page_141 next page >